package com.tong.wms.config;

import lombok.Data;

@Data
public class Result {
    private Integer code;
    private String msg;
    private Object data;
    private long total;

    public static Result fail() {
        return result(400, "error", null, 0L);
    }

    public static Result success() {
        return result(200, "success", null, 0L);
    }

    public static Result success(Object data) {
        return result(200, "success", data, 0L);
    }

    public static Result success(Object data, Long total) {
        return result(200, "success", data, total);
    }

    public static Result result(int code, String msg, Object data, Long total) {
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        result.setTotal(total);
        result.setData(data);

        return result;
    }
}
